//
//  ListDetailViewController.m
//  EducationAdminClient
//
//  Created by kwsdzjx on 15/11/26.
//  Copyright © 2015年 周佳兴. All rights reserved.
//

#import "ListDetailViewController.h"
#import "ListDetailCell.h"
#import "EditDataController.h"
#import "AddViewController.h"
#import <CommonCrypto/CommonDigest.h>
#import "UILabel+StringFrame.h"
#import "NSString+InputCheck.h"
#import "SCAlertController.h"
#import "AssesmentController.h"
#import "postPicViewController.h"
#import "SeeingThePDFViewController.h"

#import "BQActivityView.h"
#import "CustomizedAddViewController.h"
#import "FileListController.h"
#import "TabBarOccupyingController1.h"

#import "ChakanErWEiMaController.h"

#define DownLoadStudentHomeWorkFile 3//第四个作业附件
#define DownLoadStudentCompleteFile 4//完成附件
#define DownLoadStudentCorrectFile 5//第六个学员上传的附件

#define DownTeacherHomeWorkFile 6//作业附件
#define DownTeacherCompleteFile 7//完成附件
#define DownTeacherCorrectFile 8//下载附件


@interface ListDetailViewController()<UIAlertViewDelegate,UIActionSheetDelegate,UIPreviewActionItem>
@property(nonatomic,retain)UIView          *rightNavView;
@property(nonatomic,strong)NSArray         *fieldArr;
@property(nonatomic,assign)BOOL            isNULL;
@property(nonatomic,strong)NSDictionary    *deleDic;
@property(nonatomic,strong)NSDictionary    *EditDic;
@property(nonatomic,retain)NSMutableDictionary *EditBtn;
@property(assign, nonatomic)BOOL           defaultRightViewH;
@property(strong, nonatomic)UIButton       *editBtnS;
@property(strong, nonatomic)UIButton       *deleBtnS;
@property(strong, nonatomic)NSMutableArray *btnArr;
@property(assign, nonatomic)NSInteger      hiddenCount;//有几个mongodbId字段
@property(strong, nonatomic)NSMutableArray *needDownloadArr;//记录哪个cell需要点击下载
@property(strong, nonatomic)NSMutableArray *needMutArr;//章节内容数组
@property(assign, nonatomic)NSInteger      i;//记录确认下课按钮位置
@property(assign, nonatomic)NSInteger      j;//记录作业按钮位置
@property(strong, nonatomic)NSString       *btnOneName;//按钮合一的第一个按钮名字
@property(strong, nonatomic)NSString       *btnTwoName;//按钮合一的第二个按钮名字
@property(strong, nonatomic)NSString       *btnNewName;//合成后按钮名字
@property(strong, nonatomic)NSString       *zhuomei_mainID;//合成后按钮名字
@end

@implementation ListDetailViewController


-(void)viewDidLoad{
    [super viewDidLoad];
    if (_isFromStudentMore) {
        self.cusTabView.hidden = YES;
    }
    _hiddenCount = 0;
    for (int i = 0;i<_cnName.count;i++) {
        NSDictionary *dic = [_cnName objectAtIndex:i];
        if ([[dic objectForKey:@"fieldCnName"] isEqualToString:@"作业"]) {
            [_cnName removeObjectAtIndex:i];
            break;
        }
    }
    _btnOneName = @"教学日志";
    _btnTwoName = @"作业";
    _btnNewName = @"确认下课";
    [self SaveMongodbIdCound];//保存可下载的个数（即需要隐藏的个数）
    if (_hiddenCount) {
        self.imageMongoArr = [[NSMutableArray alloc] init];
        self.mp3MongoArr   = [[NSMutableArray alloc] init];
        self.mongodbIDOneArr  = [[NSMutableArray alloc] init];
        self.mongodbIDTwoArr = [[NSMutableArray alloc] init];
        self.mongodbIDThreeArr = [[NSMutableArray alloc] init];
        self.fileMongoArr = [[NSMutableArray alloc] init];
        
        if (_hiddenCount == 3) {
            self.mongodbIDOneArr = [self SaveMongodbID:_cnName.count-3];
            self.mongodbIDTwoArr = [self SaveMongodbID:_cnName.count-2];
            self.mongodbIDThreeArr = [self SaveMongodbID:_cnName.count-1];
            NSLog(@"%@",_mongodbIDOneArr);
            NSLog(@"%@",_mongodbIDTwoArr);
            NSLog(@"%@",_mongodbIDThreeArr);
        }else if (_hiddenCount == 2){
            self.mongodbIDOneArr = [self SaveMongodbID:_cnName.count-2];
            self.mongodbIDTwoArr = [self SaveMongodbID:_cnName.count-1];
            //            self.mongodbIDThreeArr = [self SaveMongodbID:_cnName.count-1];
            NSLog(@"%@",_mongodbIDOneArr);
            NSLog(@"%@",_mongodbIDTwoArr);
            NSLog(@"%@",_mongodbIDThreeArr);
        }else if (_hiddenCount == 1){
            self.mongodbIDOneArr = [self SaveMongodbID:_cnName.count-1];
            //            self.mongodbIDTwoArr = [self SaveMongodbID:_cnName.count-2];
            //            self.mongodbIDThreeArr = [self SaveMongodbID:_cnName.count-1];
            NSLog(@"%@",_mongodbIDOneArr);
            NSLog(@"%@",_mongodbIDTwoArr);
            NSLog(@"%@",_mongodbIDThreeArr);
        }
        
        _needDownloadArr = [[NSMutableArray alloc] init];
    }
    
    
    
    
    // 先获取权限 是否有按钮权限 由于历史问题先做的这个功能
    self.buttons = [ButtonsFilter textButton:self.pageId andBtnArr:self.buttons];
    // 再获取是否可显示
    NSArray *showButtonsArr = [[[ButtonsFilter alloc]init] listDetailButtonArrFilter:_buttons andDetailDic:_detailDic];
    _buttons = (NSMutableArray *)showButtonsArr;
  
    //    [buttons enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL * _Nonnull stop) {
    //        NSString *str = [NSString stringWithFormat:@"%@_%@", self.pageId, [dic valueForKey:@"buttonId"]];
    //        BOOL can = [[[ButtonsFilter alloc]init] textButton: str]; // textButton(str);
    //        if (!can&&![userName() isEqualToString:@"admin"]) {
    //            [self.buttons removeObject:dic];
    //        }
    //
    //    }];

    
    for (int i = 0; i<_cnName.count; i++) {
        NSString *name = [[_cnName objectAtIndex:i] objectForKey:@"fieldCnName"];
        //这里添加功能判断
        if (getEnglishLanguage()) {
            NSRange range = [name rangeOfString:@"Attachment of"];
            if (range.location != NSNotFound) {
                [_needDownloadArr addObject:[NSString stringWithFormat:@"%d",i]];
            }
        }else{
            NSRange range = [name rangeOfString:@"附件"];
            if (range.location != NSNotFound) {
                [_needDownloadArr addObject:[NSString stringWithFormat:@"%d",i]];
            }
        }

        
    }
    
    
    [self createLeftNavBar];
    if (_detailTitle) {
        //这里添加功能判断
        if (getEnglishLanguage()) {
            [self setTitleLabelText:@"personal information"];
        }else{
            [self setTitleLabelText:_detailTitle];
        }

        
    }else{
        [self setTitleLabelText:@"资料"];
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            [self setTitleLabelText:@""];
        }else{
            [self setTitleLabelText:@""];
        }
    }
    
    
    
    _isNULL = YES;
    _EditDic= [[NSDictionary alloc]init];
    _deleDic= [[NSDictionary alloc]init];
    
    
    [self creatRightNav];
    //    [self FounctionData];
    [self creatUI];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(reloadDetails) name:@"changeSuccess" object:nil];
    
}

-(void)reloadDetails{
    
}

-(void)creatRightNav{
    UIButton *rightBtn;
    if (_isFromStudentMore) {
        //这里添加功能判断
        if (getEnglishLanguage()) {
            rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 50, 25)];
//            [rightBtn setBackgroundColor:[UIColor redColor]];
            rightBtn.titleLabel.textAlignment = NSTextAlignmentRight;
            rightBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        }else{
            rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 45, 25)];
        }

        
    }else{
        rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 45, 25)];
    }

    
    [rightBtn addTarget:self action:@selector(rightClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    //#ifdef Main
    
    if([getUIStyle() isEqualToString:STYLE0]){
        
        NSArray *showButtonsArr = [[[ButtonsFilter alloc]init] listDetailButtonArrFilter:_buttons andDetailDic:_detailDic];
        if (showButtonsArr.count == 0) {
            rightBtn.hidden = YES;
        }else{
            rightBtn.hidden = NO;
        }
        if (_isFromStudentMore) {
            //这里添加功能判断
            if (getEnglishLanguage()) {
                [rightBtn setTitle:@"Modify" forState:UIControlStateNormal];
            }else{
                [rightBtn setTitle:@"修改" forState:UIControlStateNormal];
            }

            
        }else{
            [rightBtn setImage:[UIImage imageNamed:@"更多操作_"] forState:UIControlStateNormal];
        }
        
    }else{
        //#elif Student
        NSArray *showButtonsArr = [[[ButtonsFilter alloc]init] listDetailButtonArrFilter:_buttons andDetailDic:_detailDic];
        if (showButtonsArr.count == 0) {
            rightBtn.hidden = YES;
        }else{
            rightBtn.hidden = NO;
        }
        [rightBtn setImage:[UIImage imageNamed:@"often_More"] forState:UIControlStateNormal];
    }
    
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = item;
}

-(void)rightClick{
    //    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"更多操作" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:nil otherButtonTitles:nil, nil];
    //    actionSheet.tintColor =[UIColor redColor];
    NSArray *showButtonsArr =_buttons; //  [[[ButtonsFilter alloc]init] listDetailButtonArrFilter:_buttons andDetailDic:_detailDic];
    //#if Student
    
    if(![getUIStyle() isEqualToString:STYLE0]){
        
        if (showButtonsArr.count == 0) {
            return ;
        }
        
    }
    //#endif
    //    UIAlertController *at =[UIAlertController alertControllerWithTitle:nil message:@"更多操作" preferredStyle:UIAlertControllerStyleActionSheet];
    
    //    UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    //    }];
    //
    
    if (_isFromStudentMore) {
        NSDictionary *dic;
        if (_buttons.count>0) {
            dic = _buttons[0];
            if ([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"12"]) {
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"13"]){
                [self deleteBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"15"]){
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"18"]){
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"21"]){
                [self zhijiecaozuo:dic];
            }
            NSLog(@"%@", _btnArr);
            
        }else{
            
        }
        
        return;
    }
    
    SCAlertController *at;
    SCAlertAction *cancelAction;
    //这里添加功能判断
    if (getEnglishLanguage()) {
        at = [SCAlertController alertControllerWithTitle:@"More" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
        cancelAction = [SCAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
    }else{
        at = [SCAlertController alertControllerWithTitle:@"更多操作" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
        cancelAction = [SCAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    }
    
    
    
    
    //取消
    
    
    //单独修改一个按钮的颜色
    
    [at addAction:cancelAction];
    
    
    //#ifdef Main
    if([getUIStyle() isEqualToString:STYLE0]){
        
        NSLog(@"主项目程序");
        
    }else{
        //#elif Student
        
        NSLog(@"学员端程序");
        at.tintColor = [UIColor colorWithHex:0xef5152];
        cancelAction.textColor = [UIColor colorWithHex:0xef5152];
        //        at.view.tintColor = [UIColor colorWithHex:0xef5152];
    }
    //#elif Teacher
    //    //    rootview
    //    NSLog(@"老师端程序");
    //#else
    //
    //    NSLog(@"都不是");
    //#endif
    //        [at addAction:cancelAction];
    
    
    
    
    
    
    //    for(NSDictionary *dic in showButtonsArr){
    //        UIAlertAction *okAction     = [UIAlertAction actionWithTitle:[dic objectForKey:@"buttonName"] style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
    //            // 点击确定按钮时 要进行的操作可以写到这里
    //            if ([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"12"]) {
    //                [self addBtnClick:dic];
    //            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"13"]){
    //                [self deleteBtnClick:dic];
    //            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"15"]){
    //                [self addBtnClick:dic];
    //            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"18"]){
    //                [self addBtnClick:dic];
    //            }
    //
    //
    //        }];
    //        [at addAction:okAction];
    //    }
    //
    
    BOOL isThreeInOne = false;
    _i = 0;
    _j = 0;
    for (; _i<showButtonsArr.count; _i++) {
        NSDictionary *dic = [showButtonsArr objectAtIndex:_i];
        
        NSString *str = [NSString stringWithFormat:@"%@",[dic objectForKey:COMPOSESIGNKEYSTRING]];
        if ([str isEqualToString:@"YES"]) {
            isThreeInOne = YES;
        }
//        NSString *btnName = [NSString stringWithFormat:@"%@",[dic objectForKey:@"buttonName"]];
//        NSRange range = [btnName rangeOfString:_btnOneName];
//        if (range.location != NSNotFound) {
//            for (; _j<showButtonsArr.count; _j++) {
//                NSDictionary *indic = [showButtonsArr objectAtIndex:_j];
//                NSString *btnName = [NSString stringWithFormat:@"%@",[indic objectForKey:@"buttonName"]];
//                NSRange range1 = [btnName rangeOfString:_btnTwoName];
//                if (range1.location != NSNotFound) {
//                    isThreeInOne = YES;
//                    break;
//                }
//            }
//            break;
//        }
    }
    
    
    
    for(NSDictionary *dic in showButtonsArr){
        
        NSString *str = [NSString stringWithFormat:@"%@",[dic objectForKey:COMPOSESIGNKEYSTRING]];
        if ([str isEqualToString:@"YES"]) {
//            NSString *nameStr1 = [NSString stringWithFormat:@"%@", [showButtonsArr[_i] valueForKey:@"buttonName"]];
//            NSString *nameStr2 = [NSString stringWithFormat:@"%@", [showButtonsArr[_j] valueForKey:@"buttonName"]];
//            if (([nameStr1 containsString:_btnOneName]||[nameStr1 containsString:_btnTwoName])&&([nameStr2 containsString:_btnOneName]||[nameStr2 containsString:_btnTwoName])) {
//            break;
                NSString *englishTitle;
                //这里添加功能判断
                if (getEnglishLanguage()) {
                    englishTitle = @"End the Class";
                }else{
                    englishTitle = _btnNewName;
                }
            
                SCAlertAction *okAction     = [SCAlertAction actionWithTitle:englishTitle style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
                    [self addBtnClickNew:dic]; // 定制化 按钮
                }];
                [at addAction:okAction];
                
                
//                [self presentViewController:at animated:YES completion:^{
//                    
//                }];
                break;
//                return;
//            }
        }
        
        
        SCAlertAction *okAction     = [SCAlertAction actionWithTitle:[dic objectForKey:@"buttonName"] style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
            // 点击确定按钮时 要进行的操作可以写到这里
            
            if ([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"12"]) {
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"13"]){
                [self deleteBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"15"]){
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"18"]){
                [self addBtnClick:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"21"]){
                [self zhijiecaozuo:dic];
            }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"19"]){
                if([[dic valueForKey:@"buttonName"] isEqualToString:@"复制签字地址"]||[[dic valueForKey:@"buttonName"] isEqualToString:@"签字二维码"]){
                    [self qingqiuLianjieWith:dic];
                }else{
                  [self gotoSchedule];
                }
                
            }
            
            
        }];
        [at addAction:okAction];
    }
    
    
    _buttons = showButtonsArr;
    
    
    [self presentViewController:at animated:YES completion:^{
        
    }];
    //[self presentViewController:at animated:YES completion:nil];
}

-(void)qingqiuLianjieWith:(NSDictionary *)dic{
    NSLog(@"%@",_detailDic);
    NSString *mainid = [_detailDic objectForKey:@"LMF_ID"];
    NSString *stuname = [_detailDic objectForKey:@"STU_NAME"];
    NSString *ss = [NSString stringWithFormat:@"%@_%@",_tableId,_pageId];
//    NSMutableString * fds = [[NSMutableString alloc]init];
//    fds = [dic objectForKey:@"startTurnPageUrl"];
//    NSString *replaceStr= [fds stringByReplacingOccurrencesOfString:@"yjyj_edus_auto/" withString:@""];
    NSString *url1 =[NSString stringWithFormat:@"%@%@&domId=%@&newAddId=%@&tableId=%@&STU_NAME=%@",titleUrl,[dic objectForKey:@"startTurnPageUrl"],ss,mainid,_tableId,stuname];
    url1=[url1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:url1];
    
    
    // 2 创建请求对象
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    // 2.1 创建请求方式 (默认是get这一步可以不写)
    [request setHTTPMethod:@"get"];

    // 3 创建响应对象(有时会出错)
    NSURLResponse *response= nil;

    // 4 创建连接对象(同步)
    NSError *error;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSString *string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = string;
    

    
    if([[dic valueForKey:@"buttonName"] isEqualToString:@"复制签字地址"]){
     [self.view makeToast:@"复制成功可以粘贴了" duration:0.5 position:CSToastPositionCenter];
    }else{
        ChakanErWEiMaController *cc =[[ChakanErWEiMaController alloc]init];
        [self.navigationController pushViewController:cc animated:YES];
        cc.urlStr = string;
        cc.name = [_detailDic objectForKey:@"STU_NAME"];
    }
    

    
}

-(void)gotoSchedule{
    TabBarOccupyingController1 *tabView = [[TabBarOccupyingController1 alloc]init];
    [self.navigationController pushViewController:tabView animated:YES];
    _zhuomei_mainID = [_detailDic objectForKey:@"LMF_ID"];
    tabView.zhuomei_mainId = _zhuomei_mainID;
    tabView.forthPageDic = _detailDic;
    
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    self.cusTabView.userInteractionEnabled = NO;
    //*** the notifications
    
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:YES];
    self.cusTabView.userInteractionEnabled = YES;
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.cusTabView.hidden = YES;
    if (getTeacherInfo()) {
        NSLog(@"%@",_detailDic);
        NSLog(@"%@",getTeacherInfo());
        NSDictionary *dic = getTeacherInfo();
        NSString *phone;
        NSString *introduce;
        if ([dic objectForKey:@"t0_au_2_4139_1888"]) {
            phone = [dic objectForKey:@"t0_au_2_4139_1888"];
        }
        if ([dic objectForKey:@"t0_au_2_4139_4839"]) {
            introduce = [dic objectForKey:@"t0_au_2_4139_4839"];
        }
        NSMutableDictionary *mutDic = [NSMutableDictionary dictionaryWithDictionary:_detailDic];
        if (phone) {
            [mutDic setObject:phone forKey:@"AFM_2"];
        }
        NSString *name = @"AFM_12";
        for (NSDictionary *dic in _cnName) {
            if ([[dic objectForKey:@"fieldCnName"] isEqualToString:@"Introducation"]) {
                name = [dic objectForKey:@"fieldAliasName"];
            }
        }
        if (introduce) {
            [mutDic setObject:introduce forKey:name];
        }
        _detailDic = [NSDictionary dictionaryWithDictionary:mutDic];
        
        NSDictionary *beforeDic = personalDic();
        NSLog(@"beforeDic:%@",beforeDic);
        savePersonalDic(_detailDic);
        NSDictionary *afterDic = personalDic();
        NSLog(@"afterDic:%@",afterDic);
        
        
        cancelTeacherInfo();
        [self.tbView reloadData];
        
    }
    
}

-(void)deleItem:(NSDictionary *)dic{
    NSLog(@"dele");
    NSMutableDictionary *parmas = [[NSMutableDictionary alloc]init];
    [parmas setObject:userName() forKey:@"loginName"];
    [parmas setObject:passWord() forKey:@"password"];
    [parmas setObject:self.pageId forKey:@"pageId"];
    [parmas setObject:self.tableId forKey:@"tableId"];
    NSString *tableStr = self.tableId;
    NSString *t_str = [NSString stringWithFormat:@"T_%@_0",tableStr];
    if([_detailDic objectForKey:t_str])[parmas setObject:[_detailDic objectForKey:t_str] forKey:@"delIds"];
    [parmas setObject:[dic objectForKey:@"buttonType"] forKey:@"buttonType"];
    
    [parmas setObject: getSessionId() forKey:@"sessionId"];
    
    NSString *requestStr =[NSString stringWithFormat:@"%@%@", self.programaUrl, DELETE_URL];
    
    [NetRequest requestUrl:requestStr andParamas:parmas andReturnBlock:^(NSData *data, NSError *error) {
        
        if(!error&&data!=nil){
            //*** post the notifacation center should reload list view controller
            [[NSNotificationCenter defaultCenter]postNotificationName:@"shouldReload" object:@"ok"];
            NSString *str = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
            NSLog(@"%@", str);
            
            NSDictionary *obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
            if ([obj valueForKey: @"promptMessage"]) {
                [[NSNotificationCenter defaultCenter]postNotificationName:@"relogin" object:@"relogin"];
                
            }
            
            UIAlertView *alert =[[UIAlertView alloc]initWithTitle:nil message:str delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
            [alert show];
            NSTimer *timer;
            timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(doTime:) userInfo:alert repeats:NO];
            
            [timer fire];
            //        ListsViewController *lv= [[ListsViewController alloc]init];
        }else{
            NSString *str = [NSString stringWithFormat:@"%@", error.localizedDescription];
            [self showLabelWithText:str];
        }
    }];
    
}

-(void)deleBtn:(UIButton *)btn{
    if(CURRENTVERSION <9.0){
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:nil message:@"是否确认删除" delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"确定", nil];
        alert.delegate = self;
        [alert show];
    }else{
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"是否确认删除" preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *cancelAction1 = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"delete");
            
            [self deleItem:_deleDic];
            
            
        }];
        
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [alertController addAction:cancelAction];
        [alertController addAction:cancelAction1];
        [self presentViewController:alertController animated:YES completion:^{
            
        }];
        
    }
}

-(void)doTime:(NSTimer *)theTimer{
    UIAlertView *alert =(UIAlertView *)[theTimer userInfo];
    [alert dismissWithClickedButtonIndex:0 animated:NO];
    alert=NULL;
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"%ld",buttonIndex);
    if(buttonIndex==1){
        
#warning warining
        [self deleItem:_deleDic];
    }
}

-(void)editBtn:(UIButton *)btn{
    if(_EditDic&&_dataDic&&_deleDic&&_EditDic&&_ADDBTN&&[_EditDic objectForKey:@"startTurnPage"]&&[_dataDic objectForKey:@"tableId"]){
        EditDataController *ev =[[EditDataController alloc]init];
        
        ev.retureView = self.retureView;
        
        [self.navigationController pushViewController:ev animated:YES];
        ev.fieldDic = _EditDic;
        ev.dataDic = _dataDic;
        ev.detailDic = _detailDic;
        ev.EditDic = _EditDic;
        ev.ADDBTN = _ADDBTN;
    }
}

-(void)creatUI{
    
    self.tbView = [[UITableView alloc]init];
    [self.view addSubview:self.tbView];
    self.tbView.delegate = self;
    self.tbView.dataSource = self;
    self.tbView.separatorStyle =UITableViewCellSeparatorStyleNone;
    [self.tbView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.bottom.equalTo(self.view.mas_bottom);
    }];
 
}

#pragma mark - UITableViewCellDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    //    return _fieldArr.count;
    if (_hiddenCount) {
        return _cnName.count-_hiddenCount;
    }
    return self.cnName.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
    static NSString *listCell = @"listCell";
    ListDetailCell *cell;// = [tableView dequeueReusableCellWithIdentifier:listCell];
    if (cell == nil) {
        cell = [[ListDetailCell alloc]initWithReuseIdentifier:listCell];
    }
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    [cell setEditIs:NO];
    NSLog(@"indexPath.row 1> ==%ld",(long)indexPath.row);
    NSDictionary *dic = _cnName[indexPath.row];
    cell.title.text =[NSString stringWithFormat:@"%@", [dic valueForKey:@"fieldCnName"]];
    
    NSString * strText = [NSString stringWithFormat:@"%@", [dic objectForKey:@"fieldAliasName"]];

    NSString *cellNeedDisplayStr;
    if([_detailDic objectForKey:strText]){
        NSString *dicStr =[self.detailDic objectForKey:@"fieldAliasName"];
        if([[_detailDic objectForKey:strText] isKindOfClass:[NSNumber class]]){
            if([_detailDic objectForKey:strText]){

                cellNeedDisplayStr = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
            }else if([_detailDic objectForKey:dicStr]){

                cellNeedDisplayStr = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:dicStr]];
            }else{

                cellNeedDisplayStr = [NSString stringWithFormat:@"%@", @""];
            }
        }
        else{
            NSString *str1 = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
            
            
            NSString *str = @"00:00:00";
            if ([str1 rangeOfString:str].location != NSNotFound) {
                NSArray *arr = [str1 componentsSeparatedByString:@" "];
//                cell.titleLabel.text =arr[0];
                cellNeedDisplayStr = arr[0];
            }
            else{
                NSLog(@"indexPath.row 2> ==%ld",(long)indexPath.row);
                BOOL isHave = NO;
                for (int i = 0; i<_needDownloadArr.count; i++) {
                    if ([[_needDownloadArr objectAtIndex:i] isEqualToString:[NSString stringWithFormat:@"%ld",(long)indexPath.row]]) {
                        isHave = YES;
                        break;
                    }
                }
                
                if (isHave) {
                    
                    NSArray *arr = [[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]] componentsSeparatedByString:@","];
                    NSString *count;
                    //这里添加功能判断
                    if (getEnglishLanguage()) {
                        count = [NSString stringWithFormat:@"%lu",(unsigned long)arr.count];
                    }else{
                        count = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
                    }

                    
                    cellNeedDisplayStr = count;
//                    cell.titleLabel.text = count;
                    //                        cell.canEnterNextView.hidden = NO;
                    cell.canEnterNextView.hidden = NO;
                }else{
                    if (indexPath.row == 4&&_isNeedDisplayLessionPlan) {
                        NSLog(@"%@",[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]]);
                    }
                    cell.isNeedDisplayLessionPlan = YES;
                    cellNeedDisplayStr = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
//                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                   // cell.canEnterNextView.hidden = YES;
                }
                
            }
        }
        
        
    }else{
        //            cell.canEnterNextView.hidden = YES;
    }
    
    //    }else{
    //        if([_detailDic objectForKey:strText]){
    //            NSString *dicStr =[self.detailDic objectForKey:@"fieldAliasName"];
    //            //        NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",dicStr];
    //            if([[_detailDic objectForKey:strText] isKindOfClass:[NSNumber class]]){
    //                if([_detailDic objectForKey:strText]){
    //                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
    //                }else if([_detailDic objectForKey:dicStr]){
    //                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:dicStr]];
    //                }else{
    //                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", @""];
    //                }
    //            }
    //            else{
    //                NSString *str1 = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
    //
    //                NSString *str = @"00:00:00";
    //                if ([str1 rangeOfString:str].location != NSNotFound) {
    //                    NSArray *arr = [str1 componentsSeparatedByString:@" "];
    //                    cell.titleLabel.text =arr[0];
    //
    //                }
    //                else{
    //                    if ((indexPath.row == DownLoadStudentHomeWorkFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCorrectFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCompleteFile&&self.isNeedDownload)) {
    //
    //                        NSArray *arr = [[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]] componentsSeparatedByString:@","];
    //                        cell.titleLabel.text = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
    //
    //                    }else{
    //                        cell.titleLabel.text =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
    //                    }
    //
    //                }
    //            }
    //
    //
    //        }
    //    }
    cell.titleLabel.text = cellNeedDisplayStr;
    BOOL IS = cellNeedDisplayStr.validateMobile;
    if (IS) {
        
        cell.titleLabel.textColor =[UIColor colorWithHex:0xff8200];
    }else{
        cell.titleLabel.textColor =[UIColor colorWithHex:0x696969];
    }
    
    NSMutableString *mutStr = [NSMutableString stringWithFormat:@"%@", cell.titleLabel.text];
    
    if ([mutStr rangeOfString:@".00"].location != NSNotFound) {
        
        NSLog(@"%@", cell.titleLabel.text);
        NSRange range = [mutStr rangeOfString:@".00"];
        
        [mutStr replaceCharactersInRange:range withString:@""];
        cell.titleLabel.text = mutStr;
    }
    //    if (_isNeedDownload) {
    //        if (indexPath.row == DownLoadStudentCorrectFile||indexPath.row == DownLoadStudentCompleteFile||indexPath.row == DownLoadStudentHomeWorkFile) {
    //            NSString *str = cell.titleLabel.text;
    //            NSLog(@"str :%@",str);
    //            if (cell.titleLabel.text) {
    //                cell.canEnterNextView.hidden = NO;
    //            }else{
    //                cell.canEnterNextView.hidden = YES;
    //            }
    //        }else{
    //            cell.canEnterNextView.hidden = YES;
    //        }
    //    }else if (_TeacherNeedDownLoad){
    //        if (indexPath.row == DownTeacherHomeWorkFile||indexPath.row == DownTeacherCompleteFile||indexPath.row == DownTeacherCorrectFile) {
    //            NSString *str = cell.titleLabel.text;
    //            NSLog(@"str :%@",str);
    //            if (cell.titleLabel.text) {
    //                cell.canEnterNextView.hidden = NO;
    //            }else{
    //                cell.canEnterNextView.hidden = YES;
    //            }
    //
    //        }else{
    //            cell.canEnterNextView.hidden = YES;
    //        }
    //    }else{
    //        cell.canEnterNextView.hidden = YES;
    //    }
    if (_isNeedDisplayLessionPlan&&indexPath.row == 4) {
        
        
        if ([cellNeedDisplayStr isEqualToString:@""]||cellNeedDisplayStr == nil) {
            //这里添加功能判断
            if (getEnglishLanguage()) {
                cellNeedDisplayStr = @"No Data";
            }else{
                cellNeedDisplayStr = @"暂无数据";
            }

            
            cell.textLabel.hidden = YES;
            cell.title.hidden = NO;
            cell.titleLabel.hidden = NO;
        }else{
            cell.title.hidden = YES;
            cell.titleLabel.hidden = YES;
            cell.textLabel.hidden = NO;
        }
//        cell.textLabel.text = [NSString stringWithFormat:@"%@",cellNeedDisplayStr];
                        NSMutableArray * arr = [self componentsAllSeparatedByStringAndReturnAMutbleArr:cellNeedDisplayStr andString:@"#"];
                        NSString *str = @"章节内容：";
                        for (int i = 0;i<arr.count ;i++) {
                            //                        if (i == arr.count-1) {
                            //                            str = [NSString stringWithFormat:@"%@%@",str,[arr objectAtIndex:i]];
                            //                        }else{
                            str = [NSString stringWithFormat:@"%@\n%@",str,[arr objectAtIndex:i]];
                            //                        }
                            
                            
                        }
        
//        @property (nonatomic,strong)UILabel *myLabel;
//        self.myLabel = [[UILabelalloc]initWithFrame:CGRectMake(0,0, 375,100)];
//        self.myLabel.backgroundColor = [UIColorcyanColor];//天蓝色背景
//        self.myLabel.textAlignment =1;//居中
//        [self.viewaddSubview:self.myLabel];
        //这是我们的测试用的文本字符串数据
//        NSString *content = @"abc123a1b2c3你懂得888";
//        NSArray *number = @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9"];
        NSMutableAttributedString *attributeString  = [[NSMutableAttributedString alloc]initWithString:str];
//        for (int i = 0; i < content.length; i ++) {
//            //这里的小技巧，每次只截取一个字符的范围
//            NSString *a = [content substringWithRange:NSMakeRange(i, 1)];
//            //判断装有0-9的字符串的数字数组是否包含截取字符串出来的单个字符，从而筛选出符合要求的数字字符的范围NSMakeRange
//            if ([number containsObject:a]) {
//                [attributeString setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1],NSFontAttributeName:[UIFont systemFontOfSize:30/2],NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(i, 1)];
//            }
//            
//        }
        
        NSRange range = [str rangeOfString:@"章节内容："];
        
        
        [attributeString setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1],NSFontAttributeName:[UIFont systemFontOfSize:30/2],NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]} range:range];
        //完成查找数字，最后将带有字体下划线的字符串显示在UILabel上
        cell.textLabel.attributedText = attributeString;
//        self.myLabel.attributedText = attributeString;
        cell.textLabel.textColor = [UIColor colorWithHex:0x4c4c4c];
        
//        cell.textLabel.backgroundColor = [UIColor redColor];
        cell.textLabel.numberOfLines = 0;
//        cell.textLabel.text = str;
    }else{
        cell.titleLabel.hidden = NO;
        cell.title.hidden = NO;
        cell.textLabel.hidden = YES;
    }
    return cell;
}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    /*
     
     
     _mongodbIDOneArr   ---- 倒数第三个位置的附件值
     _mongodbIDTwoArr   ---- 倒数第二个位置的附件值
     _mongodbIDThreeArr ---- 倒数第一个位置的附件值
     
     
     */
    //    BOOL isHave = NO;
    //    for (int i = 0; i<_needDownloadArr.count; i++) {
    //这里添加了角色判断   不需要修改
    if (_needDownloadArr.count == 6||([getUserType()isEqualToString:UserISHPSTeacher]&&_needDownloadArr.count == 3)) {
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr firstObject]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDOneArr];
            
        }
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr objectAtIndex:1]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDTwoArr];
            
        }
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr objectAtIndex:2]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDThreeArr];
            
        }//这里添加了角色判断   不需要修改
    }else if (_needDownloadArr.count == 4||([getUserType()isEqualToString:UserISHPSTeacher]&&_needDownloadArr.count == 2)) {
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr firstObject]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDOneArr];
            
        }
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr objectAtIndex:1]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDTwoArr];
            
        }//这里添加了角色判断   不需要修改
    }else if (_needDownloadArr.count == 2||([getUserType()isEqualToString:UserISHPSTeacher]&&_needDownloadArr.count == 1)) {
        if ([[NSString stringWithFormat:@"%ld",(long)indexPath.row] isEqualToString:[_needDownloadArr firstObject]]) {
            
            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDOneArr];
            
        }
    }
    
    
    //    }
    
    //    if (_isNeedDownload && indexPath.row == DownLoadStudentHomeWorkFile) {
    //        NSLog(@"对喽");
    //        [self SaveFileKindsMethod:DownLoadStudentHomeWorkFile andArr:_mongodbIDOneArr];//如果有教师附件，加判断
    //    }
    //    if (_isNeedDownload && indexPath.row == DownLoadStudentCompleteFile) {
    //        NSLog(@"对喽");
    //        [self SaveFileKindsMethod:DownLoadStudentCompleteFile andArr:_mongodbIDTwoArr];
    //
    //    }
    //    if (_isNeedDownload && indexPath.row == DownLoadStudentCorrectFile) {
    //        NSLog(@"对喽");
    //        [self SaveFileKindsMethod:DownLoadStudentCorrectFile andArr:_mongodbIDThreeArr];
    //
    //    }
    
    //    if (_TeacherNeedDownLoad &&(indexPath.row == DownTeacherHomeWorkFile || indexPath.row == DownTeacherCompleteFile || indexPath.row == DownTeacherCorrectFile)) {
    //        if (indexPath.row == DownTeacherHomeWorkFile) {
    //            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDOneArr];
    //        }else if (indexPath.row == DownTeacherCompleteFile){
    //            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDTwoArr];
    //        }else{
    //            [self SaveFileKindsMethod:indexPath.row andArr:_mongodbIDThreeArr];
    //        }
    //
    //    }
    ListDetailCell *cell = (ListDetailCell *)[tableView cellForRowAtIndexPath:indexPath];
    NSString *titleText = [NSString stringWithFormat:@"%@", cell.titleLabel.text];
    if(titleText.length>0){
        
        
        BOOL IS = titleText.validateMobile;
        if (IS) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", @"telprompt://", titleText]]];
            
        }
    }
    //    UITableViewCell* cell = (ListDetailCell *)[tableView cellForRowAtIndexPath:indexPath];
    //    cell.selected = NO;
    
}

#pragma mark - UITableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *strLenth =@"";
    
    
    //     NSInteger row = [indexPath row];
    //     CGFloat contentWidth = cell.titleLabel.frame.size.width;
    //    NSDictionary *dic =[_fieldArr objectAtIndex:indexPath.row];
    
    NSDictionary *dic = _cnName[indexPath.row];
    float hh;
    NSString *cellNeedDisplayStr;
    if (_isNeedDisplayLessionPlan&&indexPath.row == 4) {
        
        NSString * strText = [NSString stringWithFormat:@"%@", [dic objectForKey:@"fieldAliasName"]];
        //    NSLog(@"%@", _detailDic);
        if([_detailDic objectForKey:strText]){
            NSString *dicStr =[self.detailDic objectForKey:@"fieldAliasName"];
            //        NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",dicStr];
            if([[_detailDic objectForKey:strText] isKindOfClass:[NSNumber class]]){
                if([_detailDic objectForKey:strText]){
                    strLenth =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                }else if([_detailDic objectForKey:dicStr]){
                    strLenth =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:dicStr]];
                }else{
                    strLenth =[NSString stringWithFormat:@"%@", @""];
                }
            }
            else{
                NSString *str1 = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                
                NSString *str = @"00:00:00";
                if ([str1 rangeOfString:str].location != NSNotFound) {
                    NSArray *arr = [str1 componentsSeparatedByString:@" "];
                    strLenth =arr[0];
                    
                }
                else{
                    if ((indexPath.row == DownLoadStudentHomeWorkFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCorrectFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCompleteFile&&self.isNeedDownload)) {
                        
                        NSArray *arr = [[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]] componentsSeparatedByString:@","];
                        //这里添加功能判断
                        if (getEnglishLanguage()) {
                            strLenth = [NSString stringWithFormat:@"%lu",(unsigned long)arr.count];
                        }else{
                            strLenth = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
                        }

                        
                        
                    }else{
                        strLenth =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                    }
                    
                }
            }
            
            
        }// options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
        NSLog(@"%@",strLenth);

        if ([strLenth isEqualToString:@""]||strLenth == nil) {
//            strLenth = @"1. 学习教室常用物品 backpack背包,book 书,chair 椅子,crayon 蜡笔,desk 书桌,eraser橡皮,marker 马克笔,pen 钢笔,pencil 铅笔,ruler尺子。 #2. 学习常见颜色 blue 蓝色,red 红色,green 绿色,yellow 黄色。 #3. 学习日常打招呼用语。 ";
            //这里添加功能判断
            if (getEnglishLanguage()) {
                strLenth = @"No Data";
            }else{
                strLenth = @"暂无数据";
            }

            
            return 70;
        }
        
        NSMutableArray * arr = [self componentsAllSeparatedByStringAndReturnAMutbleArr:strLenth andString:@"#"];
        NSString *str = @"章节内容：";
        for (int i = 0;i<arr.count ;i++) {
            //                        if (i == arr.count-1) {
            //                            str = [NSString stringWithFormat:@"%@%@",str,[arr objectAtIndex:i]];
            //                        }else{
            str = [NSString stringWithFormat:@"%@\n%@",str,[arr objectAtIndex:i]];
            //                        }
//            cell.textLabel.text = str;
           
        }
        NSMutableAttributedString *attributeString  = [[NSMutableAttributedString alloc]initWithString:str];
        //        for (int i = 0; i < content.length; i ++) {
        //            //这里的小技巧，每次只截取一个字符的范围
        //            NSString *a = [content substringWithRange:NSMakeRange(i, 1)];
        //            //判断装有0-9的字符串的数字数组是否包含截取字符串出来的单个字符，从而筛选出符合要求的数字字符的范围NSMakeRange
        //            if ([number containsObject:a]) {
        //                [attributeString setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1],NSFontAttributeName:[UIFont systemFontOfSize:30/2],NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(i, 1)];
        //            }
        //
        //        }
        
        NSRange range = [str rangeOfString:@"章节内容："];
        
        
        [attributeString setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1],NSFontAttributeName:[UIFont systemFontOfSize:30/2],NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]} range:range];
        //完成查找数字，最后将带有字体下划线的字符串显示在UILabel上
        
        
        UILabel *la =[[UILabel alloc]init];
        la.attributedText = attributeString;
        la.numberOfLines = 0;
        hh = [la sizeThatFits:CGSizeMake(KWIDTH-97, CGFLOAT_MAX)].height;//动态计算高度
        if (hh>300) {
            hh = hh-arr.count*4;
        }
        
        
    }else{
        NSString * strText = [NSString stringWithFormat:@"%@", [dic objectForKey:@"fieldAliasName"]];
        //    NSLog(@"%@", _detailDic);
        if([_detailDic objectForKey:strText]){
            NSString *dicStr =[self.detailDic objectForKey:@"fieldAliasName"];
            //        NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",dicStr];
            if([[_detailDic objectForKey:strText] isKindOfClass:[NSNumber class]]){
                if([_detailDic objectForKey:strText]){
                    strLenth =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                }else if([_detailDic objectForKey:dicStr]){
                    strLenth =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:dicStr]];
                }else{
                    strLenth =[NSString stringWithFormat:@"%@", @""];
                }
            }
            else{
                NSString *str1 = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                
                NSString *str = @"00:00:00";
                if ([str1 rangeOfString:str].location != NSNotFound) {
                    NSArray *arr = [str1 componentsSeparatedByString:@" "];
                    strLenth =arr[0];
                    
                }
                else{
                    if ((indexPath.row == DownLoadStudentHomeWorkFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCorrectFile&&self.isNeedDownload)||(indexPath.row == DownLoadStudentCompleteFile&&self.isNeedDownload)) {
                        
                        NSArray *arr = [[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]] componentsSeparatedByString:@","];
                        //这里添加功能判断
                        if (getEnglishLanguage()) {
                            strLenth = [NSString stringWithFormat:@"%lu",(unsigned long)arr.count];
                        }else{
                            strLenth = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
                        }

                        
                        
                    }else{
                        
                        NSLog(@"indexPath.row 2> ==%ld",(long)indexPath.row);
                        BOOL isHave = NO;
                        for (int i = 0; i<_needDownloadArr.count; i++) {
                            if ([[_needDownloadArr objectAtIndex:i] isEqualToString:[NSString stringWithFormat:@"%ld",(long)indexPath.row]]) {
                                isHave = YES;
                                break;
                            }
                        }
                        
                        if (isHave) {
                            
                            NSArray *arr = [[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]] componentsSeparatedByString:@","];
                            NSString *count;
                            //这里添加功能判断
                            if (getEnglishLanguage()) {
                                count = [NSString stringWithFormat:@"%lu",(unsigned long)arr.count];
                            }else{
                                count = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
                            }
                            
                            
                            cellNeedDisplayStr = count;
                            //                    cell.titleLabel.text = count;
                            //                        cell.canEnterNextView.hidden = NO;
//                            cell.canEnterNextView.hidden = NO;
                        }else{
                            if (indexPath.row == 4&&_isNeedDisplayLessionPlan) {
                                NSLog(@"%@",[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]]);
                            }
//                            cell.isNeedDisplayLessionPlan = YES;
                            cellNeedDisplayStr = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                            //                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
                            // cell.canEnterNextView.hidden = YES;
                            
                        }

                        
                        
                        strLenth = cellNeedDisplayStr;
                    }
                    
                }
            }
            
            
        }// options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
        NSLog(@"%@",strLenth);
        UILabel *la =[[UILabel alloc]init];
        la.text = strLenth;
        la.numberOfLines = 0;
        hh = [la sizeThatFits:CGSizeMake(KWIDTH-97, CGFLOAT_MAX)].height;//动态计算高度
    }
    
    
    
    
    
    
    if(hh>24){
        return hh+50;
    }else if (hh==0){
        return 70;
    }else{
        return hh+50;
    }
    
}

#pragma mark - UIActionSheet Delegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex == 0){
        return;
    }
    
    /*
     buttonPageId = 151;
     operaBtnCommitUrl = "http://10.252.46.80:8114/phone_edus_auto/update_updateInfo.do";
     operaBtnTurnUrl = "http://10.252.46.80:8114/phone_edus_auto/phone_updatePageInfo.do";
     oprBtnPageDataUrl = "http://10.252.46.80:8114/phone_edus_auto/phone_queryData.do";
     phoneButtonId = 12;
     phoneButtonName = "\U4fee\U6539";
     buttonType = 12;
     startTurnPage = 304;
     
     补卡 ---- 2天 理由 ---- 郑州出差
     系统里 补任务 ---- 写到学术任务里 --- 写去郑州干了啥 。
     */
    NSDictionary *dic = _buttons[buttonIndex-1];
    if ([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"12"]) {
        [self addBtnClick:dic];
    }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"13"]){
        [self deleteBtnClick:dic];
    }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"15"]){
        [self addBtnClick:dic];
    }else if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"18"]){
        [self addBtnClick:dic];
    }
    NSLog(@"%@", _btnArr);
    
    
}

-(void)editStyleBtnClick:(NSDictionary *)dic{
    EditDataController *ev =[[EditDataController alloc]init];
    
    if([[NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]isEqualToString:@"15"]){
        ev.edit = YES;
    }
    /*
     pageId = startTurnPage
     mainTableId = self.tableId
     mainPageId = self.pageId
     tableId = self.tableId
     mainId = T_self.tableId_0
     */
    ev.retureView = self.retureView;
    ev.fieldDic = dic;
    ev.dataDic = _dataDic;
    ev.tableId = self.tableId;
    ev.pageId = self.pageId;
    
    ev.detailDic = _detailDic;
    ev.EditDic = dic;
    ev.ADDBTN = dic;
    NSLog(@"%@", [dic valueForKey:@"phoneButtonName"]);
    
    [self.navigationController pushViewController:ev animated:YES];
    //    }
    
}

#pragma mark - 删除数据 按钮
-(void)deleteBtnClick:(NSDictionary *)dic{
    if(CURRENTVERSION <9.0){
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:nil message:@"是否确认删除" delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"确定", nil];
        alert.delegate = self;
        [alert show];
    }else{
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"是否确认删除" preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *cancelAction1 = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"delete");
            
            [self deleItem:dic];
            
            
        }];
        
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [alertController addAction:cancelAction];
        [alertController addAction:cancelAction1];
        [self presentViewController:alertController animated:YES completion:^{
            
        }];
        
    }
    
}

#pragma mark - 直接操作
-(void)zhijiecaozuo:(NSDictionary *)dic{
    
    
    NSString *btnType = [NSString stringWithFormat:@"%@", [dic valueForKey:@"buttonType"]]; // 21 时直接操作方式
    if ([btnType containsString:@"21"]) {
        // 直接操作请求地址
        NSString *requestString = [NSString stringWithFormat:@"%@%@",BASE_URL ,STRIT];
        NSString *dataId = [NSString stringWithFormat:@"%@", [self.detailDic valueForKey:@"LMF_ID"]]; // 直接操作传操作的条数据的 Id
        NSMutableDictionary *parama = [[NSMutableDictionary alloc]init];
        [parama setObject:self.tableId forKey:@"tableId"];  // 直接操作的 页面就是当前 table
        [parama setObject:self.pageId forKey:@"pageId"];    // 直接操作的页面 就是当前页面
        [parama setObject:dataId forKey:@"dataIds"];
        [parama setObject:[dic valueForKey:@"directSetIds"] forKey:@"directSetIds"]; // 直接操作 操作的直接操作 Id

        [NetRequest requestUrl:requestString andParamas:parama andReturnBlock:^(NSData *data, NSError *error) {
            if (!error&&data!=nil) {
                
                NSString *ceshiStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
                NSLog(@"strit caozuo --- ceshi ---------- %@", ceshiStr);
                if (![ceshiStr isEqualToString:@"0"]) { // 直接操作 不返回 0 即为成功
                    [self showLabelWithText:@"成功"];
                }else{
                    [self showLabelWithText:@"失败"];
                }
            }
        }];
        
    }
}
-(void)addBtnClick:(NSDictionary *)dic{
    

    NSString * btnName = [NSString stringWithFormat:@"%@", [dic objectForKey:@"buttonName"]];
    NSString *strToString = @"";
    if([btnName containsString:@"预约"]){
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            strToString = @"预约";
        }else{
            strToString = @"预约";
        }
    }else if ([btnName containsString:@"请假"]){
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            strToString = @"请假";
        }else{
            strToString = @"请假";
        }
    }else if ([btnName containsString:@"报名"]){
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            strToString = @"报名";
        }else{
            strToString = @"报名";
        }
    }else if ([btnName containsString:@"确认"]){
        //这里添加功能判断
        if (getEnglishLanguage()) {
            strToString = @"Confirm";
        }else{
            strToString = @"确认";
        }
    }else if ([btnName containsString:@"作业"]){
        //这里添加功能判断
        if (getEnglishLanguage()) {
            strToString = @"Submit";
        }else{
            strToString = @"提交";
        }
    }else if ([btnName containsString:@"日志"]){
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            strToString = @"添加";
        }else{
            strToString = @"添加";
        }
    }else if ([btnName containsString:@"评价"]){
        if ([getUserType() isEqualToString:UserISHPSTeacher]) {
            strToString = @"评价";
        }else{
            strToString = @"评价";
        }
    }
    
    if([getUIStyle() isEqualToString:STYLE0]){
        
        AddViewController *addVC = [[AddViewController alloc]init];
        
        addVC.toString = strToString;
        
        addVC.buttonDic = dic;
        
        addVC.tableId = self.tableId;
        if (_isFromStudentMore) {
            addVC.isFromStudentMore = _isFromStudentMore;
        }
        NSLog(@"%@",self.tableId);
        NSLog(@"%@",self.pageId);
        addVC.pageId = self.pageId;
        
        addVC.detailDic = _detailDic;
        addVC.retureView = self.retureView; // 设置修改用的返回视图
        if (self.TeacherNeedDownLoad == YES) {
            addVC.TeacherNeedDownLoad = YES;
        }
        [self.navigationController pushViewController:addVC animated:YES];
        
    }else{
        //#elif Student
        
        if([[dic objectForKey:@"buttonName"] isEqualToString:@"下课并评价"]){
            
            AssesmentController *asscontroller =[[AssesmentController alloc]init];
            
            asscontroller.buttonDIc = dic;
            
            asscontroller.tableId = self.tableId;
            
            asscontroller.pageId = self.pageId;
            
            asscontroller.detailDic = _detailDic;
            asscontroller.retureView = self.retureView;
            
            [self.navigationController pushViewController:asscontroller animated:YES];
            
            
        }else{
            AddViewController *addVC = [[AddViewController alloc]init];
            addVC.toString = strToString;
            
            addVC.buttonDic = dic;
            
            addVC.tableId = self.tableId;
            
            addVC.pageId = self.pageId;
            
            addVC.detailDic = _detailDic;
            addVC.retureView = self.retureView; // 设置修改用的返回视图
            
            [self.navigationController pushViewController:addVC animated:YES];
        }
    }
    
    
    
    
    
}


#pragma mark - custom ok log homeWor 3 buttons 三合一按钮
-(void)addBtnClickNew:(NSDictionary *)composeDic{
    
    NSString *strToString = @"确认"; // 提示 显示的 子 和 按钮名称
    //这里添加功能判断
    if (getEnglishLanguage()) {
        strToString = @"Confirm";
    }else{
        strToString = @"确认";
    }
    if([getUIStyle() isEqualToString:STYLE0]){
        
        CustomizedAddViewController *addVC = [[CustomizedAddViewController alloc]init];
        NSDictionary *dic1;
        NSDictionary *dic2;
        addVC.toString = strToString;
        if ([composeDic objectForKey:COMFIRM]) {
            dic1 = [composeDic objectForKey:COMFIRM];
        }
        if ([composeDic objectForKey:HOMEWORK]) {
            dic2 = [composeDic objectForKey:HOMEWORK];
        }
        
        
        if([[NSString stringWithFormat:@"%@", [dic1 objectForKey:@"buttonName"]]containsString:_btnOneName])
        addVC.buttonDic = dic1;
        addVC.buttonDicHomeWork = dic2;
        addVC.tableId = self.tableId;
        if (_isFromStudentMore) {
            addVC.isFromStudentMore = _isFromStudentMore;
        }
        NSLog(@"%@",self.tableId);
        NSLog(@"%@",self.pageId);
        addVC.pageId = self.pageId;
        
        addVC.detailDic = _detailDic;
        addVC.retureView = self.retureView; // 设置修改用的返回视图
        if (self.TeacherNeedDownLoad == YES) {
            addVC.TeacherNeedDownLoad = YES;
        }
        [self.navigationController pushViewController:addVC animated:YES];
        
    }else{
        //#elif Student
        
        
            
    }
    
    
    
    
    
}
-(void)netNotifation:(NSNotification *)noti{
    NSString *reqResStr = [noti object];
    if ([reqResStr isEqualToString:NETSTATE]&&!self.defaultRightViewH) {
        self.rightNavView.userInteractionEnabled = YES;
        
        self.rightNavView.hidden = NO;
        
    }else{
        self.rightNavView.userInteractionEnabled = NO;
        
        self.rightNavView.hidden = YES;
        
    }
    
}
#pragma mark - cell点击事件传递MongodbID数组
- (void)SaveFileKindsMethod:(NSInteger)index andArr:(NSMutableArray *)MongodbIdArray{
    
    if (_cnName.count >=4) {
        NSString *testStr = [NSString stringWithFormat:@"%@", [[_cnName objectAtIndex:index] valueForKey:@"fieldAliasName"]] ;
        NSLog(@"%@",testStr);
        
        if ([_detailDic objectForKey:testStr]) {
            NSArray *nameArr = [[_detailDic objectForKey:testStr] componentsSeparatedByString:@","];
            //                for (NSString *str in nameArr) {
            //
            //                }
            [_mp3MongoArr removeAllObjects];
            [_imageMongoArr removeAllObjects];
            [_fileMongoArr removeAllObjects];
            if (nameArr.count <= MongodbIdArray.count) {
                for (int i = 0; i < nameArr.count; i++) {
                    NSString *str = [nameArr objectAtIndex:i];
                    NSRange rangeMp3 = [str rangeOfString:@".mp3"];
                    NSRange rangeMp4 = [str rangeOfString:@".mp4"];
                    NSRange rangejpg = [str rangeOfString:@".jpg"];
                    NSRange rangejpeg = [str rangeOfString:@".jpeg"];
                    NSRange rangewav = [str rangeOfString:@".wav"];
                    //                    NSRange rangeamr = [str rangeOfString:@".amr"];
                    
                    //amr
                    NSRange rangeImage = [str rangeOfString:@".png"];//其他格式发现再说
                    
                    NSRange rangeTxt = [str rangeOfString:@".txt"];
                    NSRange rangePdf = [str rangeOfString:@".pdf"];
                    NSRange rangePPtx = [str rangeOfString:@".pptx"];
                    NSRange rangeWord = [str rangeOfString:@".doc"];
                    NSRange rangeExc = [str rangeOfString:@".xls"];
                    
                    
                    if (rangeMp3.location != NSNotFound) {
                        [_mp3MongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangeImage.location != NSNotFound){
                        [_imageMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangeMp4.location != NSNotFound){
                        [_mp3MongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangejpg.location != NSNotFound){
                        [_imageMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangejpeg.location != NSNotFound){
                        [_imageMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangewav.location != NSNotFound){
                        [_mp3MongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangeTxt.location != NSNotFound){
                        [_fileMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangePdf.location != NSNotFound){
                        [_fileMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangePPtx.location != NSNotFound){
                        [_fileMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }else if (rangeWord.location != NSNotFound){
                        [_fileMongoArr addObject:[MongodbIdArray objectAtIndex:i]];
                    }
                    //                    else if (rangeamr.location != NSNotFound){
                    //                        [_mp3MongoArr addObject:[_mongodbIDArr objectAtIndex:i]];
                    //                    }
                }
                
            }
            if(_fileMongoArr.count>0){
//                SeeingThePDFViewController *seevc =[[SeeingThePDFViewController alloc]init];
//                seevc.fileMongoArr = _fileMongoArr;
//                seevc.mongodbIDArr = MongodbIdArray;
//                seevc.nameArr = nameArr;
//                [self.navigationController pushViewController:seevc animated:YES];
                
                FileListController *seevc =[[FileListController alloc]init];
                seevc.fileMongoArr = _fileMongoArr;
                
                
                seevc.mongodbIDArr = MongodbIdArray;
                seevc.nameArr = nameArr;
                [self.navigationController pushViewController:seevc animated:YES];
            }else{
                postPicViewController *ppvc = [[postPicViewController alloc] init];
                ppvc.mp3MongoArr = _mp3MongoArr;
                ppvc.imageMongoArr = _imageMongoArr;
                
                //                if (_TeacherNeedDownLoad) {
                //                    ppvc.isNeedDownload = _TeacherNeedDownLoad;
                //                }else{
                ppvc.isNeedDownload = YES;
                //                }
                
                ppvc.mongodbIDArr = MongodbIdArray;
                
                
                
                [self.navigationController pushViewController:ppvc animated:YES];
            }
            
            
        }
    }
    
    
}


#pragma mark - 附件下载mongodbId的个数获取
-(void)SaveMongodbIdCound{
    for (NSDictionary *dic in _cnName) {
        NSString *str = [dic objectForKey:@"fieldCnName"];
        NSRange range = [str rangeOfString:@"mongodbId"];
        if (range.location != NSNotFound) {
            _hiddenCount++;
        }
    }
}

#pragma mark - 附件下载保存MongodbID数组的方法
-(NSMutableArray *)SaveMongodbID:(NSInteger)index{
    NSDictionary *dic = [_cnName objectAtIndex:index];
    NSString * strText = [NSString stringWithFormat:@"%@", [dic objectForKey:@"fieldAliasName"]];
    if([_detailDic objectForKey:strText]){
        NSString *dicStr =[self.detailDic objectForKey:@"fieldAliasName"];
        //        NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",dicStr];
        if([[_detailDic objectForKey:strText] isKindOfClass:[NSNumber class]]){
            if([_detailDic objectForKey:strText]){
                NSLog(@"这里1%@",[NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]]);
            }else if([_detailDic objectForKey:dicStr]){
                NSLog(@"这里2%@",[NSString stringWithFormat:@"%@", [_detailDic objectForKey:dicStr]]);//NSLog(@"这里%@",[NSString stringWithFormat:@"%@", ]);
            }else{
                //                    cell.titleLabel.text =[NSString stringWithFormat:@"%@", @""];
                NSLog(@"这里3%@",[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@", @""]]);
            }
        }
        else{
            NSString *str1 = [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]];
            
            NSString *str = @"00:00:00";
            if ([str1 rangeOfString:str].location != NSNotFound) {
                NSArray *arr = [str1 componentsSeparatedByString:@" "];
                NSLog(@"这里4%@",[NSString stringWithFormat:@"%@", arr[0]]);
                //                    cell.titleLabel.text =
                
            }
            else{
                //                    cell.titleLabel.text =;
                NSLog(@"这里5%@",[NSString stringWithFormat:@"%@", [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]]]);
                NSString *mongodbIDStr = [NSString stringWithFormat:@"%@", [NSString stringWithFormat:@"%@", [_detailDic objectForKey:strText]]];
                NSMutableArray *arr = [NSMutableArray arrayWithArray:[mongodbIDStr componentsSeparatedByString:@","] ];
                return arr;
                
                
            }
        }
        
        
    }
    return nil;
    
}
#pragma - mark 将所有的某个字符串作为切割条件切割字符串并返回切割后的数组
- (NSMutableArray *)componentsAllSeparatedByStringAndReturnAMutbleArr:(NSString *)string andString:(NSString *)stringTwo{
    
    
    
    NSString *aaa = string;
    NSMutableArray *array = [NSMutableArray array];
    NSRange range = [aaa rangeOfString:@"#"];
    //    while (1) {
    NSArray *arr = [aaa componentsSeparatedByString:stringTwo];
    //        [array addObject:[arr firstObject]];
    array = [NSMutableArray arrayWithArray:arr];
    //    [array removeObjectAtIndex:0];
    //        aaa = [NSString stringWithFormat:@"%@",[arr lastObject]];
    //        range = [aaa rangeOfString:@"#"];
    //        if (range.location == NSNotFound) {
    //            [array addObject:aaa];
    //            break;
    //        }
    //    }
    _needMutArr = array;
    return array;
}


-(void)dealloc{
    
}



@end
